<?php require_once('Connections/analisis2.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['usuario'])) {
  $loginUsername=$_POST['usuario'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "MenuLector.php";
  $MM_redirectLoginFailed = "fallo.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_analisis2, $analisis2);
  
  $LoginRS__query=sprintf("SELECT usuario, password FROM usuario WHERE usuario=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $analisis2) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Inicio.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Analisis y Dise&ntilde;o de Sistemas 2</title>
<!-- InstanceEndEditable -->
<link rel="stylesheet" type="text/css" href="style.css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body>
<div id="wrap">

       <div class="header">
       		<div class="logo"><br></div>            
        <div id="menu">
            <ul>                                                                       
            <li class="selected"><a href="index.php">Inicio</a></li>
            <li></li>
            <li></li>
            <li></li>
            <li><a href="login.php">Login</a></li>
            <li><a href="registro.php">Registro</a></li>
            <li></li>
            <li><a href="contact.html">Contactanos</a></li>
            </ul>
        </div>     
            
            
       </div> 
       
       
       <div class="center_content"><!-- InstanceBeginEditable name="Centro" -->
         <div class="left_content">
           <div class="title"><span class="title_icon"><img src="images/bullet1.gif" alt="" title="" /></span>Mi cuenta</div>
           <div class="feat_prod_box_details">
             <p class="details"> Login para entrar a las publicaiones </p>
             <div class="contact_form">
               <div class="form_subtitle">Entra a tu cuenta</div>
               <form METHOD="POST" action="<?php echo $loginFormAction; ?>" name="register" id="autenticacion">
                 <div class="form_row">
                   <label class="contact"><strong>Usuario:</strong></label>
                   <input id="usuario" name="usuario" type="text" class="contact_input" />
                 </div>
                 <div class="form_row">
                   <label class="contact"><strong>Password:</strong></label>
                   <input id="password" name="password" type="password" class="contact_input" />
                 </div>
                 <div class="form_row">
                   <div class="terms">
                     <p>
                       <input type="checkbox" name="terms" />
                     Remember me </p>
                     <p>
                       <input type="submit" name="cmdLogin" id="cmdLogin" value="Login" />
                     </p>
                   </div>
                 </div>
                 <div class="form_row"></div>
               </form>
             </div>
           </div>
           <div class="new_products"></div>
           <div class="clear"></div>
         </div>
       <!-- InstanceEndEditable --><!--end of left content--><!-- InstanceBeginEditable name="Derecha" -->
       <div class="right_content">
         <div class="title"><span class="title_icon"><img src="images/bullet3.gif" alt="" title="" /></span>About Our Store</div>
         <div class="about">
           <p> <img src="images/about.gif" alt="" title="" class="right" /> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud. </p>
         </div>
       </div>
       <!-- InstanceEndEditable --><!--end of right content-->
        
        
       
       
       <div class="clear"></div>
       </div><!--end of center content-->
       
              
       <div class="footer">
       	<div class="left_footer"><img src="images/footer_logo.gif" alt="" title="" /></div></div></div>

</body>
<!-- InstanceEnd --></html>